package com.jzo2o.market.controller.operation;

import cn.hutool.core.util.NumberUtil;
import com.jzo2o.common.model.PageResult;
import com.jzo2o.common.utils.NumberUtils;
import com.jzo2o.market.model.dto.request.ActivityQueryForPageReqDTO;
import com.jzo2o.market.model.dto.request.ActivitySaveReqDTO;
import com.jzo2o.market.model.dto.response.ActivityInfoResDTO;
import com.jzo2o.market.service.IActivityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ Tool：IntelliJ IDEA
 * @ Author：徐茂茂
 * @ Date：2025-10-15-22:13
 * @ Version：1.0
 * @ Description：
 */
@RestController("operationActivityController")
@RequestMapping("/operation/activity")
@Api(tags = "活动管理接口")
public class ActivityController {

    @Resource
    private IActivityService activityService;

    @PostMapping("/save")
    public void save(@RequestBody ActivitySaveReqDTO activitySaveReqDTO){


        activityService.addActivity(activitySaveReqDTO);
    }

    @GetMapping("/page")    
    public PageResult<ActivityInfoResDTO> page(ActivityQueryForPageReqDTO activitySaveReqDTO){
        return activityService.pageActivity(activitySaveReqDTO);
    }


    @GetMapping("/{id}")
    public ActivityInfoResDTO getDetail(@PathVariable("id") Long id){
        return activityService.getDetail(id);
    }
    @PostMapping("/revoke/{id}")
    @ApiOperation("撤销优惠活动")
    public void revokeActivity(@PathVariable("id") Long id){
        activityService.revokeActivity(id);
    }

}
